cmake_minimum_required(VERSION 3.5)

# 项目环境配置 ###########################################################################################################
project(janna VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# qt 库 ################################################################################################################
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# vcpkg ################################################################################################################
set(vckpg_dir "/home/laolang/program/vcpkg")
set(CMAKE_TOOLCHAIN_FILE "${vckpg_dir}/scripts/buildsystems/vcpkg.cmake")
set(fmt_DIR "${vckpg_dir}/packages/fmt_x64-linux-dynamic/share/fmt")
set(spdlog_DIR "${vckpg_dir}/packages/spdlog_x64-linux-dynamic/share/spdlog")

# fmt 库
find_package(fmt CONFIG REQUIRED)
get_target_property(fmt_LOCATION fmt::fmt LOCATION)
get_filename_component(fmt_DIRECTORY ${fmt_LOCATION} DIRECTORY)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    string(REPLACE "debug/" "" fmt_DIRECTORY ${fmt_DIRECTORY})
endif()

message(STATUS "fmt_DIRECTORY:${fmt_DIRECTORY}")

# spdlog 库
find_package(spdlog CONFIG REQUIRED)
get_target_property(spdlog_LOCATION spdlog::spdlog LOCATION)
get_filename_component(spdlog_DIRECTORY ${spdlog_LOCATION} DIRECTORY)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    string(REPLACE "debug/" "" spdlog_DIRECTORY ${spdlog_DIRECTORY})
endif()
# 不需要 debug 日志时,注释下面两行
add_compile_options(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
add_compile_options(-DJANNA_LOG_LEVEL=1)


message(STATUS "spdlog_DIRECTORY:${spdlog_DIRECTORY}")

# 项目变量配置 ###########################################################################################################
set(QRC_FILES ${PROJECT_SOURCE_DIR}/res.qrc)

# 项目配置文件
configure_file(janna_configuration.h.in ${PROJECT_SOURCE_DIR}/src/util/configuration.h)

# 包含全局头文件
include_directories(${PROJECT_SOURCE_DIR}/include)

# 通用工具类库
set(util_lib_name util)
# 简单实现发布订阅
set(pubsub_lib_name pubsub)

# 插件
set(taskbuttons_plugin_name taskbuttons)
set(taskexplorer_plugin_name taskexplorer)
set(volar_plugin_name volar)

# 添加子目录 #############################################################################################################
add_subdirectory(src)
